import itertools # fct it's just for computation of \gamma(sigma_i)(I) for I=(i,J,i+1,K) def fct(J,I): return([[I[0]+1,*I[1:I[0]],J[0],*I[I[0]:]],[*I[:I[0]+1],J[0],*I[I[0]+1:]]]) # calcplus(i,I) takes as input a positive integer "i" and a sequence "I=[i_1, ...,i_l]". Then compute \gamma(sigma_i)(i_1, ..., i_l)=coef_1[I1]+coef_2[I_2]+...+coef_m[I_m] and return the result in the form [[coef_1,I_1],[coef_2,I2], ..., [coef_m,I_m]] def calcplus (i,I): k=-1 l=-1 j=0 while (k+1)*(l+1)==0 and j0: I2=[*I[:l+1],i,*I[l+1:]] return([[1]+I0,[1]+I1,[-1]+I2]) return([[1]+I0,[1]+I1]) if k>0: if k0: I2=[*I[:k],i+1,*I[k:]] return([[1]+I0,[1]+I1,[-1]+I2]) return([[1]+I0,[1]+I1]) if k>0: if k0: return([[Y[0]*I[0]]+Y[1:] for I in C for Y in calcplus(i,I[1:]) if len(I)<=p+1 if len(Y)<=p+1]) if i<0: return([[Y[0]*I[0]]+Y[1:] for I in C for Y in calcminus(-i,I[1:]) if len(I)<=p+1 if len(Y)<=p+1]) return([[]]) # proj_calcgene (p,i,C) take as input a positive integer "p", a sequence of relatives integer "L=[l_1, ..., l_k" and a sequence of sequence "C=[[coef_1,I_1], ..., [coef_m,I_m]]". Then it computate gamma_p(sigma_{|l_1|}^{sign(l_1)}sigma_{|l_2|}^{sign(l_2)}...sigma_{|l_k|}^{sign(l_k)})([coef_1,I_1], ..., [coef_m,I_m])=coef'_1[J_1]+...+coef'_l[J_l] and gives the result in the form [[coef'_1,J_1],[coef'_2,J_2],...,[coef'_l,J_l]]. (recall that gamma_p is the projection of the rpz on the subspace generated by commutator of weight lower or equal than p.) def proj_calcrpz(p,L,C): L.reverse() l=len(L) for i in range(0,l): C=proj_calcgene(p,L[i],C) j=0 while j0: B=T[0]*clasp(T[1:])+B #print('pour le',i,'ieme générateur on a',len(C),'éléments') if T[0]<0: B=-T[0]*inv(clasp(T[1:]))+B #print('Les claspeurs de degré',p-1,'à compenser sont donné par:',C) U=B*n simplify(U) #print('La tresse est de longueur:',len(U)) C=proj_calcrpz(n,U,[[1,n]])[1:] return(L,C)